package com.weijin.bookborrowmanagesystem.mapper;

import com.weijin.bookborrowmanagesystem.pojo.Borrow;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author WeiJin
 * @Version 1.0
 * @Date 2025/3/13 10:40
 */
@Mapper
public interface BorrowMapper {
    @Select("select count(*) from t_borrow where user_id = #{userId} and return_time is null")
    int selectUnReturnCount(@Param("userId") int userId);


    @Insert("insert into t_borrow(user_id,book_id,borrow_time,days) values (#{userId},#{bookId},#{borrowTime},#{days})")
    int insert(Borrow borrow);

    @Select("select * from t_borrow where user_id = #{userId} and book_id = #{bookId} and return_time is null")
    Borrow selectUnReturnByUserAndBook(@Param("userId") int userId,@Param("bookId") int bookId);

    int updateCondition(Borrow borrow);

    List<Borrow> selectListCondition(Integer userId);
}
